package face.pay.web.enterprise.controller.mchpayinfo;

import face.pay.common.enterprise.service.IMchPayInfoService;
import face.pay.entity.EnterpriseInfo;
import face.pay.entity.UserInfo;
import face.pay.security.annotation.CurrentUser;
import face.pay.security.exception.BaseException;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/mch_pay_info")
public class MchPayInfoController {

    @Autowired
    private IMchPayInfoService iMchPayInfoService;

    /**
     * oem查看下面的商家
     * 支付配置信息
     *
     * @return
     */
    @RequestMapping("/list")
    public String manager() {
        return "enterprise/mch_pay_info";
    }


    /**
     * 分页查询当前oem商下的商家
     * @param loginUser
     * @param enterpriseInfo
     * @param pageParam
     * @return
     * @throws BaseException
     */
    @RequestMapping("/queryData")
    @ResponseBody
    public PageData data(@CurrentUser UserInfo loginUser, EnterpriseInfo enterpriseInfo, PageParam pageParam) throws BaseException {
        enterpriseInfo.setOemId(loginUser.getOemId());
        enterpriseInfo.setDeleted(0);
        return this.iMchPayInfoService.queryPage(enterpriseInfo, pageParam);
    }


    /**
     * 编辑商家支付资料
     * @param
     * @return
     * @throws BaseException
     */
    @RequestMapping("/edit")
    @ResponseBody
    public ResultMessage editMchPayInfo(@CurrentUser UserInfo loginuser, EnterpriseInfo enterpriseInfo) throws BaseException {
        enterpriseInfo.setUpdatedBy(loginuser.getId());
        return  this.iMchPayInfoService.editMchPayInfo(enterpriseInfo);

    }
}
